package so.wy.servicecenter.businessbed.service.hospital;

import org.springframework.context.annotation.Scope;
import org.springframework.stereotype.Service;
import so.wy.servicecenter.base.exception.ServiceException;
import so.wy.servicecenter.base.frame.baseopt.BaseOptService;
import so.wy.servicecenter.businessbed.dao.rdb.hospital.hospital.HospitalDAO;
import so.wy.servicecenter.businessbed.dao.rdb.hospital.hospital.HospitalDO;
import so.wy.servicecenter.businessbed.service.hospital.dto.HospitalDTO;

import java.math.BigDecimal;

@Service
@Scope("prototype")
public class HospitalService extends BaseOptService<HospitalDAO, HospitalDO, HospitalDTO> {

    @Override
    protected HospitalDTO convert2DTO(HospitalDO hospitalDO) {
        return new HospitalDTO(hospitalDO);
    }

    @Override
    protected HospitalDO convert2DO(HospitalDTO hospitalQuery) {
        return hospitalQuery.convert2DO();
    }

    @Override
    public HospitalDTO addRecord(HospitalDTO recordQuery) throws ServiceException {
        recordQuery.setCountDevice(0);
        recordQuery.setCountOrder(0);
        recordQuery.setAmountTotal(new BigDecimal(0));
        recordQuery.setAmountPay(new BigDecimal(0));
        recordQuery.setAmountPayFree(new BigDecimal(0));
        return super.addRecord(recordQuery);
    }
}
